package com.example.chatservice.rabbitmq.publisher;

import lombok.extern.slf4j.Slf4j;
import org.example.entity.constants.Constants;
import org.example.entity.dto.MessageSendDto;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description
 * @Author susu
 * @Date 2024/10/7
 */
@Component
@Slf4j
public class ChatPublisher {
    @Resource
    private RabbitTemplate rabbitTemplate;


    public void userSendMsg2Group(MessageSendDto messageSendDto){
        rabbitTemplate.convertAndSend(Constants.EXCHANGE_CHAT_TOPIC_NAME,Constants.GROUP_QUEUE_ROUTING_KEY,messageSendDto);
        log.info("消息已发送:编号{}",messageSendDto.getMessageId());
    }
}
